import React from "react";
export interface FirstViewProps {
  sampleP?: string;
}
export interface FirstViewState {
  sampleS?: number;
}
export default class FirstView extends React.Component<
  FirstViewProps,
  FirstViewState
> {
  static defaultProps = {
    // sampleP: "primary",
  };
  target1 = React.createRef<HTMLInputElement>();
  target2 = React.createRef<HTMLInputElement>();
  constructor(props: FirstViewProps) {
    super(props);
    this.state = {
      sampleS: 1,
    };
    console.log("构造期 ", this.target1);
    this.target2.current?.focus();

  }
  componentDidMount(): void {
    console.log("componentDidMount");
    console.log("渲染期 ", this.target1);
  }

  //   method like:
  //   sampleM = () => {
  //   };
  handle = () => {
    console.log("操作期 target", this.target2);
    console.log("操作期current", this.target2.current);
    this.target2.current?.focus();
    const t = this.target2.current!.value;
    console.log(t);
  };
  render(): React.ReactNode {
    return (
      <>
        <button onClick={this.handle}>FirstView</button>
        <input ref={this.target1} />
        <input ref={this.target2} defaultValue={1} />
        {/* <button onClick={this.go}>{this.state.sampleS}</button> */}
      </>
    );
  }
}
